import Vue from 'vue'

Vue.directive('blur', {
  bind: function() {},
  inserted: function(el, type) {

  },
  update: function(el) {
    el.children[0].onblur = function(e) {
      if (!new RegExp(/(^[\-0-9][0-9]*(.[0-9]+)?)$/).test(el.children[0].value)) {
        el.children[0].value = 1
      }
    }
  },
  componentUpdated: function(el) {

  },
  unbind: function() {}
})
